package org.xxx.epms.models.epms.controller;


import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.xxx.epms.common.api.CommonResult;
import org.xxx.epms.models.epms.model.GridProvince;
import org.xxx.epms.models.epms.service.GridProvinceService;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lb
 * @since 2024-06-08
 */
@RestController
@RequestMapping("/epms/gridProvince")
public class GridProvinceController {
    @Autowired
    private GridProvinceService gridProvinceService;

    @ApiOperation("根据id查询省份信息")
    @RequestMapping(value = "/getGridProvinceById", method = RequestMethod.GET)
    public CommonResult<GridProvince> getGridProvinceById(@RequestParam("provinceId") Integer provinceId){
        GridProvince gridProvince = gridProvinceService.getGridProvinceById(provinceId);
        if(gridProvince == null){
            return CommonResult.failed("查询失败");
        }else {
            return CommonResult.success(gridProvince);
        }
    }

    @ApiOperation("展示所有省份信息")
    @RequestMapping(value = "/getAllGridProvinces", method = RequestMethod.POST)
    public CommonResult<List<GridProvince>> getAllGridProvinces(){
        return CommonResult.success(gridProvinceService.getAllGridProvinces());
    }
}

